<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page pageEncoding="UTF-8" contentType="text/html; UTF-8" isELIgnored="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>超市账单管理系统-商品管理</title>
    <link type="text/css" rel="stylesheet" href="../css/style.css">
</head>
<body>
<div class="menu">
    <table>
        <tbody>
        <tr>
            <td>
                <form method="post" action="${pageContext.request.contextPath}/product/search">
                    <input name="method" value="query" class="input-text" type="hidden"> 商品名称：<input name="productName" class="input-text" type="text" value="">&nbsp;&nbsp;&nbsp;&nbsp;
                    <input value="查 询" type="submit">
                </form>
            </td>
        </tr>
        </tbody>
    </table>
</div>
<div class="main">
    <div class="optitle clearfix">
        <em><input value="添加商品" class="input-button" onclick="window.location='${pageContext.request.contextPath}/product/addView'" type="button"></em>
        <div class="title">商品管理&gt;&gt;</div>
    </div>
    <div class="content">
        <c:if test="${empty requestScope.products}">
            <div class="empty-tip">暂无商品数据</div>
        </c:if>
        <c:if test="${not empty requestScope.products}">
            <table class="list">
                <tbody>
                <tr>
                    <td width="40" height="23"><div class="STYLE1" align="center">商品编号</div></td>
                    <td width="120"><div class="STYLE1" align="center">商品名称</div></td>
                    <td width="50"><div class="STYLE1" align="center">商品类别</div></td>
                    <td width="180"><div class="STYLE1" align="center">供应商</div></td>
                    <td width="50"><div class="STYLE1" align="center">商品单价</div></td>
                    <td width="60"><div class="STYLE1" align="center">商品库存量</div></td>
                    <td width="100"><div class="STYLE1" align="center">商品条码</div></td>
                    <td width="120"><div class="STYLE1" align="center">操作</div></td>
                </tr>
                <c:forEach items="${requestScope.products.list}" var="product">
                    <tr>
                        <td width="40" height="23"><div>${product.productID}</div></td>
                        <td width="120"><div>${product.productName}</div></td>
                        <td width="50"><div>${product.category}</div></td>
                        <td width="180"><div>${product.supplier}</div></td>
                        <td width="50"><div>${product.unitPrice}</div></td>
                        <td width="60"><div>${product.currentStock}</div></td>
                        <td width="100"><div>${product.barcode}</div></td>
                        <td width="120"><div>
                            <input type="button" value="编辑" class="input-button"
                                   onclick="window.location='${pageContext.request.contextPath}/product/showdetail?productName=${product.productName}'">
                            <input type="button" value="删除" class="input-button"
                                   onclick="if(confirm('确定删除该商品？')){window.location='${pageContext.request.contextPath}/product/delete?productID=${product.productID}';}">
                        </div></td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <div style="text-align: right">
                <c:if test="${products.currentPage>1}">
                    <a href="${pageContext.request.contextPath}/product/getAll?target=1">首页</a>
                    <a href="${pageContext.request.contextPath}/product/getAll?target=${products.prePage}">上一页</a>
                </c:if>
                <c:if test="${products.currentPage < products.totalPageCount}">
                    <a href="${pageContext.request.contextPath}/product/getAll?target=${products.nextPage}">下一页</a>
                    <a href="${pageContext.request.contextPath}/product/getAll?target=${products.totalPageCount}">尾页</a>
                </c:if>
                第${products.currentPage}页/共${products.totalPageCount}页  共${products.totalPageCount}条
            </div>
        </c:if>
    </div>
</div>
</body>
</html>